<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://github.com/rbatis/rbatis_sql/raw/main/mybatis-3-mapper.dtd">
<mapper>
    <sql id="select_self">
        (menu_id,
        menu_name,
        path,
        permission,
        component,
        create_time,
        parent_id,
        del_flag,
        state
        )
    </sql>


    <select id="get_menu_by_user">
        select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component,m.state, ifnull(m.permission,'') as permission,  m.menu_type, m.icon,   m.create_time
        from menu m
        left join role_menu rm on m.menu_id = rm.menu_id
        left join user_role ur on rm.role_id = ur.role_id
        left join role ro on ur.role_id = ro.role_id
        where ur.user_id = #{userId}
    </select>
</mapper>